/*	This program produces Appendix Table C.4 */

***** Set directories 
local dir_clean 	"~/Dropbox/Retirement gaming/clean"
local dir_output 	"~/Dropbox/Retirement gaming/output/dataverse"

use "`dir_clean'/mainsample_medbcw.dta", clear

** SUMMARY STATISTICS HOURS BY SECTOR (Table C.4)**
cap drop indgr
g indgr= 1 if ciiu1==2	// manufacturing
replace indgr = 2 if ciiu1==5 // retail
replace indgr = 3 if ciiu1==6	// transport comm
replace indgr = 4 if ciiu1==7 | ciiu1==8	// services
		
xtset i t
xtsum hrsmonth if empl==1  & indgr==1
matrix Variance = (r(mean),r(sd),r(sd_b),r(sd_w),r(N),r(n))
foreach C in 2 3 4 {
	xtsum hrsmonth if empl==1  & indgr==`C'
	matrix Variance = Variance\(r(mean),r(sd),r(sd_b),r(sd_w),r(N),r(n))
}
matrix rownames Variance = Manufacturing Retail_Hospitality Transport_Comm Services 
matrix colnames Variance = Mean Variance Between Within N Individuals
matrix list Variance
esttab matrix(Variance, fmt(1 1 1 1 0 0)) using "`dir_output'/tableC4.tex", ///
		 style(tex) f nogaps nomtitles replace
		
clear all
exit
